package com.example.booking.controller;

import java.util.HashMap;

import javax.websocket.server.PathParam;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.fasterxml.jackson.core.sym.Name;

//控制器：接收所有的请求 
//RESTful 风格控制器
@RestController
public class HellwController {
	//GET /brith?y=2000&m=7&d=2
	//GET /brith/2000/7/2	
	@GetMapping("/brith/{year}/{month}/{day}")
	private HashMap<String, Object> brith(	
			@PathVariable int year,
			@PathVariable int month,
			@PathVariable int day) {
		
		HashMap<String, Object> data = new HashMap<>() {};
		data.put("星座", "白羊");
		data.put("生肖", "龙");
		data.put("年", year);
		data.put("月", month);
		data.put("日", day);
		
		return data;

	}
	
	//GET http://127.0.0.1:8080/
	@GetMapping("/")
	public String hello( @RequestParam(defaultValue = "") String name) {
		return "hello spring" + name;
	}
	//GET http://127.0.0.1:8080/bye
	@GetMapping("/bye/{name}")
	public String bye( @PathVariable String name) {
		return "再见"+ name;
	}
}
